<?php
/*
 * @Description: 
 * @Author: Leequik
 * @Date: 2025-08-21 22:54:33
 * @LastEditTime: 2025-08-21 23:18:15
 * @LastEditors: Leequik
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\applicationHookLimit;

class applicationHookLimitController extends Controller
{
    public function index()
    {
        $applicationHookLimit = applicationHookLimit::all();
        return response()->json($applicationHookLimit);
    }

    public function loop()
    {

        $applicationIds = applicationHookLimit::groupBy('application_id')
            ->havingRaw('COUNT(*) > 1')
            ->pluck('application_id');

        // 获取详细信息并格式化
        $results = applicationHookLimit::whereIn('application_id', $applicationIds)
            ->get()
            ->groupBy('application_id')
            ->map(function ($group) {
                return $group->pluck('limit', 'entry_type');
            })
            ->toArray();
           
           dd($results);
            // ->get()
            // ->toArray();

            // foreach ($results as $applicationId => $entryTypes) {
            //     foreach ($entryTypes as $entryType => $limit) {
            //         $results[$applicationId][$entryType] = [
            //             'limit' => $limit,
            //             'used' => $this->getUsedCount($applicationId, $entryType),
            //         ];
            //     }
            // }
            return response()->json($results);
        }

    public function ktov()
    {
        
    }



}
